<?php
/**
 * @author Amissah Gideon<kuulmek@yahoo.com>
 * @access public
 * @version 1.0
 */
?>
<script type="text/javascript">
    var global_creditors = <?php echo json_encode($creditors_data); ?>;
</script>
<style type="text/css">
    @media only screen and (min-width: 768px) {
        /* Form layouts */
        /*.inline-label > .label{
            width: 120px;
        }*/
</style>

<!-- Main content -->
<section role="main" id="main">

    <!-- Header -->
    <?php
        echo $this->element('page_header');
        echo $this->element('navigations/sales_navbar');
    ?>

    <div class="with-padding">
        <div class="columns">
            <div class="new-row-mobile twelve-columns six-columns-tablet twelve-columns-mobile">

                <h3 class="thin underline">Make Repayment For Sales</h3>
                <p class="wrapped left-icon icon-info-round">
                    <b><?php  echo __('Transaction Currency:');?> <strong id="trans_curr_lbl"></strong></b>  <input type="hidden" id="gbl_currency" value="" />
                    &nbsp;&nbsp;
                    &nbsp;&nbsp;<?php  echo __('USD Conversion Rate:');?> <input type="text" id="conversion_rate" size="5" class= "input usd_rate_text" value="<?php echo $buying_usd_rate;?>" />
                </p>
            </div>
            <div class="new-row-tablet new-row-mobile six-columns twelve-columns-tablet twelve-columns-mobile">

                <?php echo $this->Form->create('SaleCreditPayment', array('default' => false, 'id' => 'form', 'action' => 'add','inputDefaults' => array('label' => false,'div' => false)));?>
                <fieldset class="fieldset">
                    <legend class="legend">Info</legend>

                    <p class="button-height inline-label">
                        <label class="label">Customer On Credit:</label>
                        <?php echo $this->Form->input('c_customer_id', array('div' => false, 'label' => false, 'id' => 'c_customer_id', 'class' => 'select expandable-list', 'style'=>'width:220px;', 'options' => $creditors, 'default'=>''.$last_entry['Sale']['customer_id'].'')); ?>
                        <?php echo $this->Form->input('currency', array('type'=>'hidden','div' => false, 'label' => false, 'id' => 'currency', 'class' => '', 'value' => '')); ?>
                        <?php echo $this->Form->input('usd_rate', array('type'=>'hidden','div' => false, 'label' => false, 'id' => 'usd_rate', 'class' => '', 'value' => '')); ?>
                    </p>

                    <p class="button-height inline-label">
                        <label class="label">Sale Transactions:</label>
                        <?php echo $this->Form->input('sale_id', array('div' => false, 'label' => false, 'id' => 'sale_id', 'class' => 'select expandable-list', 'style'=>'width:220px;','options' => array())); ?>
                        <?php echo $this->Form->input('set_default_sale', array('type'=>'hidden','div' => false, 'label' => false, 'id' => 'set_default_sale', 'class' => '', 'value' => ''.$last_entry['Sale']['id'].'')); ?>
                    </p>

                    <p class="button-height inline-label" id="amt_expected_txt">
                        <label class="label">Amount Expected:</label>
                        <span><b>0.00</b></span>
                    </p>

                    <p class="button-height inline-label">
                        <label class="label">Amount Tendered Currency:</label>
                        <?php echo $this->Form->input('paid_amount_currency', array( 'div' => false, 'label' => false, 'id' => 'paid_amount_currency', 'class' => 'select', 'options' => $currency_opts, 'default' => 'GHc'));  ?>
                    </p>

                    <p class="button-height inline-label">
                        <label class="label">Amount Tendered:</label>
                        <?php echo $this->Form->input('original_paid_amount', array('type'=>'text','div' => false, 'label' => false, 'id' => 'original_paid_amount', 'class' => 'input validate[required,custom[number]]', 'value'=>'0.00')); ?>
                        <?php echo $this->Form->input('paid_amount', array('type' => 'hidden', 'div' => false, 'label' => false, 'id'=>'paid_amount' ,'class' => '', 'value'=>'0.00')); ?>
                    </p>

                    <p class="button-height inline-label" id="amt_tendered_rate_txt">
                        <label class="label">Amount Tendered USD:</label>
                        <span><b>0.00</b></span>
                    </p>

                    <p class="button-height inline-label">
                        <label class="label">Payment for Date:</label>
                        <span class="input">
                            <?php echo $this->Form->input('pay_date', array('type'=>'text','id'=>'pay_date', 'class' => 'input-unstyled validate[required]',  'value'=>date('Y-m-d'),'readonly' => 'readonly','div' => false, 'label' => false,)); ?>
                            <a href="javascript:void(0)" class="button compact" id="pay_date_btn">Date</a>
                        </span>
                    </p>

                    <p class="button-height inline-label">
                        <label class="label">Payment Type:</label>
                        <?php echo $this->Form->input('pay_type', array('id'=>'pay_type', 'class' => 'select' ,'options'=>$pay_type_opt,'div' => false, 'label' => false,)); ?>
                    </p>

                    <p class="button-height inline-label">
                        <label class="label">Comments:</label>
                        <?php echo $this->Form->input('comments', array('id'=>'comments', 'class' => 'input full-width', 'div' => false, 'label' => false,)); ?>
                    </p>

                    <p class="button-height inline-label">
                        <label for="print_receipt" class="label">Print Receipt</label>
                        <input type="checkbox" name="print_receipt" class="switch medium" id="print_receipt" value="1" checked="checked" data-text-on="Yes" data-text-off="No"/>
                        <?php /*echo $this->Form->input('print_receipt', array('type'=>'checkbox','div' => false, 'label' => false, 'id'=>'print_receipt' ,'class' => '', 'checked'=>'checked')); */?>
                    </p>

                    <p class="button-height inline-label">
                        <label for="save-btn" class="label">&nbsp;</label>
                        <button type="button" class="button" id="save-btn">
                            <span class="button-icon green-gradient"><span class="icon-download"></span></span>
                            Save
                        </button>

                        <button type="button" class="button" id="cancel-btn">
                            <span class="button-icon anthracite-gradient"><span class="icon-cross-round"></span></span>
                            Cancel
                        </button>
                    </p>

                </fieldset>

                <?php echo $this->Form->end();?>

            </div>

            <!-- Credit Transaction Details -->

            <div class="new-row-tablet new-row-mobile six-columns twelve-columns-tablet twelve-columns-mobile">

                <div class="boxed credit-detail-window">
                    <p>Sale's Transaction Detail</p>
                    <ul class="bullet-list">

                    </ul>
                </div>

            </div>
        </div>
    </div>

</section>
<!-- End main content -->

<!-- Side tabs shortcuts -->
<?php echo $this->element('side_tabs_shortcuts'); ?>
<!-- Sidebar/drop-down menu -->
<?php echo $this->element('right_side_infos'); ?>


<!-- Users URL -->
<input type="hidden" id="table-url" value="<?php echo $this->Html->url(array('controller' => 'Sales', 'action' => 'get')); ?>" />
<input type="hidden" id="add-edit-url" value="<?php echo $this->Html->url(array('controller' => 'Sales', 'action' => 'add')); ?>" />
<input type="hidden" id="load-user-url" value="<?php echo $this->Html->url(array('controller' => 'Sales', 'action' => 'load')); ?>" />
<input type="hidden" id="delete-url" value="<?php echo $this->Html->url(array('controller' => 'Sales', 'action' => 'delete_')); ?>" />
<input type="hidden" id="print-receipt-url" value="<?php echo $this->Html->url(array('controller' => 'Sales', 'action' => 'print_receipt')); ?>" />

<?php
echo $this->Html->script('setup.js');

/** Template functions **/
echo $this->Html->script('developr.input.js');
echo $this->Html->script('developr.message.js');
echo $this->Html->script('developr.modal.js');
echo $this->Html->script('developr.navigable.js');
echo $this->Html->script('developr.notify.js');
echo $this->Html->script('developr.scroll.js');
echo $this->Html->script('developr.progress-slider.js');
echo $this->Html->script('developr.tooltip.js');
echo $this->Html->script('developr.confirm.js');
echo $this->Html->script('developr.agenda.js');
echo $this->Html->script('developr.tabs.js');

echo $this->Html->script('libs/tinycon.min.js');
echo $this->Html->script('jquery.thfloat-0.3.min.js');
echo $this->Html->script('custom-scripts/repayment.js');
?>